#include <stdio.h>

void BubbleSort(int *arr, int n);
int main()
{
    int a[] = {8,3,10,9,11,14,7,6,20,18,17,65,13,19,18};
    printf("排序前");
    for (int i = 0; i < 15; i++)
    {
        printf("%d,",  a[i]);
        
    }
    printf("\n");
    BubbleSort(a, 15);
    printf("\n排序后");
    for (int i = 0; i < 15; i++)
    {
        printf("%d,",  a[i]);
        
    }
    printf("\n");
    return 0;
}

void BubbleSort(int *arr, int n){
    if(arr==NULL || n<2){
        return;
    }
    int i,j;
    int temp;
    for ( i = n-1; i >0; i--)
    {
        for ( j = 0; j < n-1; j++)
        {
            if(arr[j]>arr[j+1]){ 
                // 交换
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
        
    }
    
    return;
}





